package myJlite.service;

import java.sql.SQLException;
import java.util.List;

import jvlite.authority.AuthLoader;
import jvlite.core.JLiteContext;
import jvlite.mvc.annotaion.Insert;
import jvlite.mvc.annotaion.PointCut;
import jvlite.util.StrUtil;
import myJlite.dao.IChartsDAO;
import myJlite.entity.ProfitVO;
import myJlite.entity.StaffVO;

@PointCut(advice = "examAdvice", value = "")
public class ChartsService implements IChartsService {
	@Insert(value = "chartsDAO")
	IChartsDAO chartsDAO;
	
	@Override
	public List<StaffVO> readDeptSlr(Integer dept_id) throws SQLException{
		 return this.chartsDAO.readDeptSlr(dept_id);
	};
	@Override
	public List<ProfitVO> readProfitByDeptId(Integer dept_id) throws SQLException{
		return chartsDAO.readProfitByDeptId(dept_id);		
	}
	@Override
	public Boolean login(StaffVO staffVO) throws SQLException{
		List<StaffVO> usrVOs = chartsDAO.login(staffVO);
		if (StrUtil.objNotEmpty(usrVOs) && usrVOs.size() == 1){
			JLiteContext.curUser = usrVOs.get(0);
			new AuthLoader().configAuth();
			return true;
		} else {
			return false;
		}
	}
}
